<?php
class Controller_Admin_AppStat extends Controller_Template 
{
    public function __construct($req, $res) {
		parent::__construct($req, $res);
		$this->template = "smarty:statistics/appstat/hidden";
	}
	
	/**
	 * 广告饱和度统计
	 *
	 */
	public function action_hidden_pkg_stat()
	{
	    $error_tips    = '';
	    $result = array();
	    $query         = $this->request->query();
	    $start_date    = Arr::get($query, 'start_date', date('Y/m/d'));
	    $end_date      = Arr::get($query, 'end_date', date('Y/m/d'));
	    $pkgname       = Arr::get($query, 'pkgname', '');
	    if ($start_date != $end_date && $pkgname == '')
	    {
	        $error_tips = '跨天查询请输入要查询的包名，查某天所有请设置开始结束一样并清空包名';
	    }
	    else
	    {
	        $result = AppStat::hidden_pkg_stat($pkgname, $start_date, $end_date);
	    }
	    $this->template->set('start_date', $start_date);
	    $this->template->set('end_date', $end_date);
	    $this->template->set('pkgname', $pkgname);
	    $this->template->set('result', $result);
	    $this->template->set('error_tips', $error_tips);
	    $this->template->set('data_count', count($result));
	    $this->template->set_filename("smarty:statistics/appstat/hidden");
	}
}
